package com.projectmodel.rocketmq.controller;

import com.projectmodel.rocketmq.service.KafkaProducerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class KafkaController {

    @Autowired
    private KafkaProducerService kafkaProducerService;

    @PostMapping("/produce")
    public String producer() {
        String topic = "topicfirst";
        for(int i=0;i<10;i++){
            kafkaProducerService.sendMessage(topic,"key:"+i,"hello kafka "+i);
        }
        return "success";
    }
}
